package Thread;

/**
 * 线程等待
 */
public class ThreadJoin {
    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(()->{
            System.out.println(Thread.currentThread().getName()+"正在学习javaSE的知识~~");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        },"javaSE线程~~");
        Thread t2=new Thread(()->{
            System.out.println(Thread.currentThread().getName()+"正在学习数据结构的知识~~");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        },"数据结构线程~~");

        System.out.println("先学习javaSE~~");
        t1.start();
        t1.join();
        //此时t1线程已经执行结束
        t2.start();
        t2.join();
        //此时t2线程已经执行结束
        System.out.println("开始学习javaweb的知识~~");
    }

}